//
//  SMSRequestProvider.m
//  SulitLoan
//
//  Created by 虞嘉伟 on 2025/2/26.
//


#import "Item1UserInfoRequestProvider.h"
#import "Item1GetUserInfoRequest.h"
#import "Item1UpdateUserInfoRequest.h"

@implementation Item1UserInfoRequestProvider

// 获取用户信息
+ (void)requestGetUserInfoWithProductID:(NSString *)productId success:(void(^)(NSDictionary *dict))success failure:(void(^)(YTKRequest *request))failure {
    Item1GetUserInfoRequest *request = [Item1GetUserInfoRequest new];
    request.scenery = productId;
#ifdef DEBUG
    //request.scenery = @"2";
#endif
    [request startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        NSDictionary *dict = request.responseObject;
        if (![dict isKindOfClass:NSDictionary.class]) {
            !failure ?: failure(request);
            return;
        }
        if ([dict[@"weeps"] intValue] == 0) {
            // 成功
            //HomeModel *model = [HomeModel modelWithJSON:dict[@"bounding"]];
            !success ?: success(dict[@"bounding"]);
        } else {
            !failure ?: failure(request);
        }
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        !failure ?: failure(request);
    }];
}

// 保存用户信息
+ (void)requestUpdateUserInfoWithBirthday:(NSString *)birthday
                               cardNumber:(NSString *)cardNumber
                                 username:(NSString *)username
                                 cardType:(NSString *)cardType
                                  success:(void(^)(NSDictionary *dict))success
                                  failure:(void(^)(YTKRequest *request))failure {
    Item1UpdateUserInfoRequest *request = [Item1UpdateUserInfoRequest new];
    request.originality = birthday;
    request.genial = cardNumber;
    request.veins = username;
    request.monthly = cardType;
#ifdef DEBUG
    //request.scenery = @"2";
#endif
    [request startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        NSDictionary *dict = request.responseObject;
        if (![dict isKindOfClass:NSDictionary.class]) {
            !failure ?: failure(request);
            return;
        }
        if ([dict[@"weeps"] intValue] == 0) {
            // 成功
            //HomeModel *model = [HomeModel modelWithJSON:dict[@"bounding"]];
            !success ?: success(dict[@"bounding"]);
        } else {
            !failure ?: failure(request);
        }
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        !failure ?: failure(request);
    }];
}


@end
